<div id="tracking-table-wrapper">
<table id="tracking-table" class="tablesorter sticky-enabled">
    <tr><th>Campaign</th><th>Start Date</th><th>End Date</th><th>Team</th><th>Team Goal</th><th>My Achievement</th><th>Individual Goal</th></tr>
    <?php foreach ($data as $key => $value) : ?>
        <tr class="orderRow">
            <td><a href="javascript:void(0);" id="campaign_<?php echo $key; ?>"><?php echo $value['campaign_title']; ?></a></td>
            <?php
            $start = explode('T', $value['start_time']);
            $end = explode('T', $value['end_time']);
            ?>
            <td><?php echo $start[0]; ?></td>
            <td><?php echo $end[0]; ?></td>
            <td><?php 
            if ($value['team']['nid'] != -1)
            echo $value['team']['title']; ?></td>
            <td><?php 
            if ($value['team']['nid'] != -1)
            echo '$' . $value['team']['goal']; ?></td>
            <td><?php echo '$' . $value['amount_money']; ?></td>
            <td><?php echo '$' . $value['individual_goal']; ?></td>
        </tr>
        <?php foreach ($value['product_list'] as $item) : ?>
            <tr class="expand-child productList campaign_<?php echo $key; ?>">
                <td></td>
                <td></td>
                <td><a href="javascript:void(0);" id="<?php echo $key . '_' . $item['nid']; ?>"><?php echo $item['title']; ?></td>
                <td><?php echo '$' . ($item['cost'] + $item['price']); ?></td>
                <td><?php echo $item['qty']; ?></td>
                <td><?php echo '$' . ($item['cost'] + $item['price']) * $item['qty']; ?></td>
            </tr>
            <?php foreach ($item['purchase_details'] as $info): ?>
                <tr class="purchaseDetails <?php echo $key . '_' . $item['nid']; ?>">
                    <td></td>
                    <td></td>
                    <td></td>
                    <td><?php echo $info['user']->name ?></td>
                    <td><?php echo $info['qty'] ?></td>
                    <td><?php echo date('Y-m-d', $info['date']); ?></td>

                </tr>
            <?php endforeach; ?>
        <?php endforeach; ?>
    <?php endforeach; ?>
</table>
</div>
<?php echo $pager; ?>

